//
//  HRSubMitOrderViewController.m
//  haierapp
//
//  Created by Xia Zhiyong on 14-8-14.
//  Copyright (c) 2014年 haier. All rights reserved.
//

#import "HRSubMitOrderViewController.h"
#import "HRPaymentManager.h"
#import "HRPaysucceedViewController.h"

@interface HRSubMitOrderViewController ()

@end

@implementation HRSubMitOrderViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (__CUR_IOS_VERSION >= __IPHONE_7_0)
    {
        self.edgesForExtendedLayout= UIRectEdgeNone;
    }
    self.navigationItem.title = @"订单确认";
    _viewBg.layer.borderWidth = 1;
    _viewBg.layer.borderColor = [UIColor colorFromHexRGB:@"dcdcdc"].CGColor;
    _viewBg.layer.cornerRadius = 3;
    
    _lblPrice.text = _price;
    _lblNumber.text = _orderNum;
    
    [self.navController showBackButtonWith:self andAction:@selector(back)];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)back{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (IBAction)actionSure:(id)sender {
    
    [HRPaymentManager paymentWithOrderId:_orderNum subject:self.subject body:@"暂无" amount:_price completion:^(BOOL isSucceed, NSString *message) {
        if (isSucceed) {
            //更改订单状态
            [HRCommonData shareCommonData].hasNewOrder=YES;
            [HRCommonData shareCommonData].hasNewShopCar = YES;
            //push到支付成功页面
            HRPaysucceedViewController *viewC = [[HRPaysucceedViewController alloc] initWithNibName:@"HRPaysucceedViewController" bundle:nil];
            viewC.pushType = PUSH_FROM_SUBMIT;
            [self.navigationController pushViewController:viewC animated:YES];
            
        }else{
            [self showTextHUD:message];
        }

    }];
}
@end
